﻿using System;
using System.Collections.Generic;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;

namespace Ue.Qcdz.Domain.ShopArticle
{
    public class ShopNewsService
    {
        private static IShopNewsRepository repository;

        static ShopNewsService()
        {
            ShopNewsService.repository = RepositoryFactory.GetRepository<IShopNewsRepository, ShopNews>();
        }
        public static ShopNews GetShopNews(object shopNewsKey)
        {
            return ShopNewsService.repository.FindBy(shopNewsKey);
        }

        public static IList<ShopNews> GetShopNews()
        {
            return ShopNewsService.repository.FindAll();
        }
        public static IDataResult<ShopNews> GetShopNews(IShopNewsDataQuery dataQuery)
        {
            return ShopNewsService.repository.FindBy(dataQuery);
        }

        public static void AddShopNews(ShopNews shopNews)
        {
            ShopNewsService.repository.Add(shopNews);
        }

        public static void RemoveShopNews(ShopNews shopNews)
        {
            ShopNewsService.repository.Remove(shopNews);
        }
        public static void RemoveShopNews(object shopNewsKey)
        {
            ShopNews shopNews = ShopNewsService.repository.FindBy(shopNewsKey);
            if (shopNews == null)
            {
                throw new ArgumentOutOfRangeException("shopNewsKey");
            }

            ShopNewsService.repository.Remove(shopNews);
        }

        public static void UpdateShopNews(ShopNews shopNews)
        {
            ShopNewsService.repository[shopNews.Key] = shopNews;
        }

        public static void RemoveAll(Shops.Shop shop)
        {
            ShopNewsService.repository.RemoveAll(shop);
        }
    }
}
